import { Process, Processor } from '@nestjs/bull';
import { Job } from 'bull';
import { Inject } from '@nestjs/common';
import { VideoService } from './video.service';


@Processor('video')
export class VideoProcessor {
    constructor(
        @Inject(VideoService)
        private readonly video: VideoService,
    ) {
    }

    @Process({concurrency: 1})
    async transcode(job: Job<{ filepath: string, dirpath: string, targetpath: string }>) {
        const {filepath, dirpath, targetpath} = job.data;
        await this.video.action(filepath, targetpath);
    }
}
